﻿using CnManageCpp;
using testclr;
using LoadingWK;

using System;
using DevExpress.XtraBars;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;


namespace DisplayTableData
{
    public partial class MianWindow : DevExpress.XtraBars.TabForm
    {
        private SlabTrackGeoCLR _slabTrackGeo = new SlabTrackGeoCLR();
        private clrClass _function = new clrClass();
        private AirplanLoading _airplanLoading = new AirplanLoading();

        public MianWindow()
        {
            InitializeComponent();
        }
        void OnOuterFormCreating(object sender, OuterFormCreatingEventArgs e)
        {
            MianWindow form = new MianWindow();
            form.TabFormControl.Pages.Clear();
            e.Form = form;
            OpenFormCount++;
        }
        static int OpenFormCount = 1;

        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            string languageName = Properties.Settings.Default.language; //LaguageSetting.GetLanguage();
            switch (languageName)
            {
                case "en-US":
                    languageName = "zh-CN";
                    MessageBox.Show("切换成中文(重启后生效！)");
                    break;
                case "zh-CN":
                    languageName = "en-US";
                    MessageBox.Show("Switch the language to English (Valid after reboot!)");
                    break;
            }
            Properties.Settings.Default.language = languageName;
            Properties.Settings.Default.Save();
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(languageName);
        }

        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            int sum = _slabTrackGeo.add(12, 16);
            barEditTest.EditValue = sum.ToString();
        }

        private void chartControl1_Click(object sender, System.EventArgs e)
        {

        }

        private void ribbonStatusBar1_Click(object sender, System.EventArgs e)
        {

        }

        private void barButtonItem2_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            //clrClass ClrCLass = new clrClass();
            //double value = ClrCLass.add(1.2, 3.9);
            //value += 1;
            LoadedEquipmentList list =  _airplanLoading.startLoading(10);

        }

        private void barButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
        {
            for(int i = 1; i <= 10; i++)
            {
                DataType data = new DataType();
                data.set(i * 2, Convert.ToUInt64(i));
                _function.addIter(data);
            }

            DataList list = _function.getDataList();
            decimal value = list._weight;
            for (int i = 0; i<list.getCount();i++)
            {
                value = list._list[i]._value;
                value = list._list[i]._type;
            }
        }
    }
}
